# Contributor: Karim Kanso <kaz.kanso@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=daq
pkgver=2.0.7
pkgrel=0
pkgdesc="Data Acquisition library - packet I/O library"
url="https://www.snort.org/"
arch="all"
license="GPL-2.0-only"
makedepends="libpcap-dev flex bison linux-headers libnetfilter_queue-dev
	libnfnetlink-dev libdnet-dev automake autoconf libtool"
subpackages="$pkgname-static $pkgname-sfbpf $pkgname-dev"
source="https://www.snort.org/downloads/snort/daq-$pkgver.tar.gz
	fix-includes.patch
	"

prepare() {
	default_prepare
	# files ore somehow read-only in the archive
	chmod -R +w "$srcdir"
	autoreconf -fi
}

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var
	# work around parallel build issue
	make -C sfbpf tokdefs.h
	make
}

check() {
	cd "$builddir"
	make check
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
}

sfbpf() {
	pkgdesc="snort's berkley packet filter shared lib"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libsfbpf.so* "$subpkgdir"/usr/lib/
}

sha512sums="9bedddbc2d952526ab4e1d65f4507eb914507f8b3b5702ecf7137f8a210c690703469162a117a76cb8376a5639db46bd767fc48789ba7294a0bad26d4cd0ede2  daq-2.0.7.tar.gz
ea769608e4b6ebfd186a5e637a1dbf16f300c5c40501655b891fdc0095879f65927d90872d4953a4a4e32ccc40306b19a1a1e7ae4dd8b3f7572db97aea48390e  fix-includes.patch"
